#include <QtGui>
#include "point_graph.h"

Point_Graph::Point_Graph(double step, Point point, Playdesk *table, int x, int y)
{
    None_Flag = true;
    size = step * 0.9;
    if (point == Blue) color = Qt::blue;
    if (point == Red) color = Qt::red;
    if (point == None) None_Flag = false;
    playdesk = table;
    this->x = x;
    this->y = y;
}

QRectF Point_Graph::boundingRect() const
{
    return QRectF(-0.5*size, -0.5*size, size, size);
}

void Point_Graph::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if (None_Flag)
    {
        Q_UNUSED(option);
        Q_UNUSED(widget);
        painter->setPen(QPen(Qt::blue, 1));
        painter->setBrush(QBrush(color));
        painter->drawEllipse(-0.25*size, -0.25*size, size*0.5, size*0.5);
    }
}

void Point_Graph::mousePressEvent(QGraphicsSceneMouseEvent *)
{
    QPoint point(x,y);
    playdesk->SetPoint(point);
    //playdesk->compcolor=2;
    //playdesk->addPoint(x,y,2);
}

